/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { ModalForm } from '@ant-design/pro-form';
import { Button, Image } from 'antd';
import normalize from '@/utils/rules';
import React from 'react';
import styles from './index.less';

interface Modal {
  visible: boolean;
  preData: any;
  onVisibleChange?: (e: React.MouseEvent<HTMLElement>) => void;
}

const Index = (props: Modal) => {
  const { visible, preData, onVisibleChange } = props;
  const { ad_url = '', name = '', lottery_time = '', desc = '' } = preData;

  return (
    <ModalForm
      className={styles.previewModal}
      visible={visible}
      modalProps={{
        onCancel: onVisibleChange,
      }}
      submitter={{
        render: () => (
          <Button type='primary' onClick={onVisibleChange}>
            确定
          </Button>
        ),
      }}
    >
      <Image
        width={375}
        src='https://osscdn-kbad.kuaidihelp.com/admin/ad/2023/02/27/63fc4f401f613/detail.png'
        preview={false}
      />
      <div className={styles.lImg}>
        <Image width={160} src={ad_url} preview={false} />
      </div>
      <div className={styles.name}>{name}</div>
      <div className={styles.lottery_time}>{lottery_time}</div>
      <div
        className={styles.desc}
        dangerouslySetInnerHTML={{ __html: normalize('line', '<br>', desc) }}
      ></div>
    </ModalForm>
  );
};

export default Index;
